<%-- 
    Document   : printDiscussion
    Created on : May 2, 2012, 11:11:14 PM
    Author     : rakesh reddy
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
       <table align="center">
            <thead>
                <tr>
                    <th><h1>CS 425 Project </h1></th>
                </tr>
            </thead>
        </table>
        <table cellpadding=4 cellspacing=2 border=0 align="center" width="500" >
                <th bgcolor="#efefef" colspan=2>
                <font size=5> Discussions </font>
                <br><font size=1><sup></sup></font><hr>
                </th>
                <tr bgcolor="#efefef">
                    <td width="50">
                        <p><b><h4>Discussion Title: </h4> </b> <%=request.getAttribute("title")%></p>
                        <p><h4>Related to: </h4></p>
                        <p><b>Movie Name: </b><%=request.getAttribute("mname")%></p>
                        <p><b>Theater Name: </b><%=request.getAttribute("tname")%> </p>
                        <p><b>Visits: </b><%=request.getAttribute("vis")%></p>
                        <p><b>Posted By: </b><%=request.getAttribute("uname")%></p>
                        
                    </td>  
                    <td>
                        <p> <h3> Discussion CONTENT : </h3> </p>
                    <p><%=request.getAttribute("cont")%></p>
                                       
                    </td>
                  </tr>
                  <tr>
                      <td></td>
                      <%String name = (String) session.getAttribute("name");%>
        
            <% if (name != null) { %>
                      <td>
                      <FORM METHOD="post" ACTION="addComment" align="center">
                          <input type="text" name="comm" value="" size=75 maxlength="300">
                          
                          <input type="submit" value="Comment">
                          <input type="hidden" name="dis_id" value="<%=request.getAttribute("dis_id")%>">
                               <input type="hidden" name="mname" value="<%=request.getAttribute("mname")%>">
                               <input type="hidden" name="uname" value="<%=request.getAttribute("uname")%>">
                               
                               <input type="hidden" name="tname" value="<%=request.getAttribute("tname")%>">
                               <input type="hidden" name="vis" value="<%=request.getAttribute("vis")%>">
                               <input type="hidden" name="cont" value="<%=request.getAttribute("cont")%>">
                               <input type="hidden" name="title" value="<%=request.getAttribute("title")%>">
                                <input type="hidden" name="memid" value="<%=request.getAttribute("memid")%>">
                          
                      </form>
                          </td>
                          <% } %>
                      </tr>
                      
                      
                    <%
                    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();  
                    Connection con1 = DriverManager.getConnection("jdbc:oracle:thin:@fourier.cs.iit.edu:1521:orcl","rjairaj","cs425dbo");  
                    Statement stmt1= con1.createStatement();  
                    Object dis_id=(request.getAttribute("dis_id"));
                    
                    System.out.println("****dis_id:"+dis_id);
                    ResultSet rs1 = stmt1.executeQuery("select content,member_id from (select content,member_id from discussion_reply where discussion_id='"+dis_id+"' order by reply_id desc) where rownum<=10");
                    %>
                           <tr><td>Comments</td></tr>
                    <%
                           while(rs1.next()){
                        %>
                        <tr bgcolor="#efefef"><td><p> posted by User(ID): <%=rs1.getInt(2)%></p></td><td><p> <h5> Comment:</h5> <%=rs1.getString(1)%> </p></td></tr>  
                      
                        <%
                    }
                        %>       
                          
                          
                          
                      
        </table>
    </body>
</html>
